//
//  SXTMyPageTableView.m
//  SYT
//
//  Created by 彭之耀 on 2017/8/27.
//  Copyright © 2017年 个人学习. All rights reserved.
//

#import "SXTMyPageTableView.h"
#import "SXTMyMessageTableViewCell.h"

@interface SXTMyPageTableView()<UITableViewDelegate,UITableViewDataSource>

@property(strong,nonatomic) NSArray *messageArray;


@end

@implementation SXTMyPageTableView

-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    self = [super initWithFrame:frame style:style];
    if (self) {
        self.delegate = self;
        self.dataSource = self;
    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
    return self.messageArray.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44.0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SXTMyMessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[SXTMyMessageTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.sourceDic = self.messageArray[indexPath.row];
    if (indexPath.row == 3) {
        //        UIImageView *nextImg = [cell valueForKey:@"nextImage"];
        //        [nextImg removeFromSuperview];
        //        nextImg = nil;
        //        nextImg.hidden = YES;
        //        UILabel *phoneNum = [[UILabel alloc]init];
        //        phoneNum.text = @"400-100-1111";
        //        phoneNum.textColor = rgb(123, 124, 128);
        //        [cell addSubview:phoneNum];
        //
        //        __weak typeof (cell) weakCell = cell;
        //        [phoneNum mas_makeConstraints:^(MASConstraintMaker *make) {
        //            make.right.equalTo(weakCell.mas_right).offset(-15);
        //            make.centerY.equalTo(weakCell.mas_centerY);
        //            make.size.mas_equalTo(CGSizeMake(100, 15));
        //        }];
        
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    SXTLog(@"我选中的是第%li行",indexPath.row);
}

-(NSArray *)messageArray{
    if (_messageArray == nil) {
        _messageArray = @[@{@"title":@"我的收藏",@"image":@"我的界面我的收藏图标"},
                          @{@"title":@"已经反馈",@"image":@"我的界面意见反馈图标"},
                          @{@"title":@"关于我们",@"image":@"我的界面关于我们图标"},
                          @{@"title":@"客服热线",@"image":@"我的界面客服热线图标"},
                          @{@"title":@"我的优惠券",@"image":@"我的界面我的优惠券图标"},
                          @{@"title":@"邀请好友，立刻赚钱",@"image":@"我的界面邀请好友图标"}];
    }
    return _messageArray;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
